﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
@* 工序管理列表页面 *@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet" />
</head>
<body class="layui-padding-3">
    <h3>工艺工序管理/工艺列表</h3>
    <form class="layui-form layui-row layui-col-space16">
        <div class="layui-col-md4">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix"></div>
                <label class="layui-form-label">工艺路线编号：</label><input type="text"
                                                                      name="A"
                                                                      value=""
                                                                      id="ProcessNumber"
                                                                      placeholder=""
                                                                      class="layui-input"
                                                                      lay-affix="clear"
                                                                      style="width: 200px" />
            </div>
        </div>
        <div class="layui-col-md4">
            <div class="layui-input-wrap">
                <label class="layui-form-label">工艺名称：</label>
                <input type="text"
                       name="B"
                       placeholder=""
                       lay-affix="clear"
                       id="ProcessName"
                       class="layui-input"
                       style="width: 200px" />
            </div>
        </div>
        <div class="layui-col-md4">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix"></div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block" style="width: 200px">
                        <select name="interest" lay-filter="aihao" id="ProcessAudit">
                            <option value="0">选择状态</option>
                            <option value=true>有效</option>
                            <option value=false>无效</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-btn-container layui-col-xs12">
            <a class="layui-btn" onclick="location.href='/Process/ProcessAdd'">
                添加
            </a>
            <button type="reset" class="layui-btn layui-btn-primary">批量删除</button>
            <button type="reset" class="layui-btn layui-btn-primary">导出</button>
            <button class="layui-btn" lay-submit lay-filter="search">
                查询
            </button>
        </div>
    </form>
    <table class="layui-hide" id="ID-table-demo-search"></table>
    <script>
        layui.use('table', function () {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            var util = layui.util;
            var table = layui.table;

            var formData = {
                ProcessNumber: "",
                ProcessName: "",
                ProcessAudit: -1,

            };
            Seach();

            // 提交事件
            form.on('submit(search)', function (data) {
                var field = data.field; // 获取表单字段值
                // 显示填写结果，仅作演示用
                formData.ProcessNumber = $("#ProcessNumber").val();
                formData.ProcessName = $("#ProcessName").val();
                formData.ProcessAudit = $("#ProcessAudit").val()
                Seach();
                return false; // 阻止默认 form 跳转
            });


            // 搜索提交
            function Seach() {
                console.log(formData);
                var ProcessUrl = '@ViewBag.RBACWrite' + "/api/Process/ProcessList?ProcessNumber=" + formData.ProcessNumber + '&ProcessName=' + formData.ProcessName + '&ProcessAudit=' + formData.ProcessAudit;
                $.ajax({
                    url: ProcessUrl,
                    type: 'get',
                    dataType: "json",
                    contentType: "application/json",
                    success: res => {
                        console.log(res);
                        table.render({
                            elem: '#ID-table-demo-search',
                            cols: [
                                [
                                    { type: 'checkbox', title: '复选框', fixed: true }, // 单选框
                                    { field: 'processId', title: '序号', width: 80 },
                                    { field: 'processNumber', title: '工序编码', width: 120 },
                                    { field: 'processName', title: '工序名称', width: 120 },
                                    { field: 'workCenterName', title: '工作中心', width: 100 },
                                    { field: 'processCreateTime', title: '创建时间', width: 100 },
                                    { field: 'processCreateName', title: '创建人', width: 100 },
                                    { field: 'processStateName', title: '状态', width: 100 },
                                    { field: 'processAuditName', title: '审批状态', width: 100 },
                                    {
                                        fixed: 'right',
                                        title: '操作',
                                        width: 134,
                                        minWidth: 125,
                                        templet: '#toolDemo',
                                    },
                                ],
                            ],
                            data: res.data,
                            page: true,
                            limits: [2, 3, 4],
                            height: 310
                        });
                        return;

                    }
                });
            };
        });
    </script>
    <script type="text/html" id="toolDemo">
        <div class="layui-clear-space">
          <a onclick="" style="color:cornflowerblue">详细</a>
          <br />
          <a onclick="" style="color:cornflowerblue;" >编辑</a>
          <br />
          <a onclick="" style="color:red">删除</a>
        </div>
    </script>
</body>
</html>

